package com.wyp168.leetcode;

/**
 * @ClassName KthGrammarSolution
 * @Title TODO
 * @Description TODO
 * @Author wyp168
 * @Date 2022/10/20 09:00
 */
public class KthGrammarSolution {
    public static void main(String[] args) {
        KthGrammarSolution solution = new KthGrammarSolution();
        int n = 1;
        int k = 1;
        System.out.println(solution.kthGrammar(n, k));
    }

    ///TODO 题解解法  ----》 myself ？？？？
    public int kthGrammar(int n, int k) {
        return n==1?0:(k % 2 == 0 ? 1 : 0)^kthGrammar(n-1,(k+1)/2);
    }
}
